#include <AppStream.hpp>
#include <FileNotFoundException.hpp>

#ifndef _CLASSMODELINGDS3STREAM_
#define _CLASSMODELINGDS3STREAM_

#define MAIN3DS       0x4D4D
#define M3D_VERSION   0x0002
  #define EDIT3DS       0x3D3D  // this is the start of the editor config
    #define EDIT_MATERIAL 0xAFFF
      #define MAT_NAME01       0xA000
      #define MAT_AMBIENT      0xA010
      #define MAT_DIFFUSE      0xA020
      #define MAT_SPECULAR     0xA030
        #define MAT_RGB1         0x0011
        #define MAT_RGB2         0x0012
      #define MAT_GLOSSINESS   0xA040
        #define DOUBLE_BYTE      0x0030
      #define MAT_SPECULAR_LEVEL 0xA041
      #define MAT_TRANSPARENCY 0xA050
      #define MAT_TRANSFALLOF  0xA052
      #define MAT_REFLECTBLUR  0xA053
      #define MAT_MATERIALTYPE 0xA100
      #define MAT_SELFILLUM    0xA084
      #define MAT_UNKNOWN      0xA087
      #define MAT_SOMTRANSFALL 0xA240
      #define MAT_SREFLECTBLUR 0xA250
      #define MAT_TWOSIDED     0xA081
      #define MAT_TRANSPADD    0xA083
      #define MAT_WIREON       0xA085
      #define MAT_FACEMAP      0xA088
      #define MAT_TRANSFALLOFF_IN 0xA08A
      #define MAT_SOFTEN       0xA08C
      #define MAT_WIRE_UNITS   0xA08E
      #define MAT_WIRE_SIZE    0xA087
      #define DIFFUSE_MAP      0xA200
      #define OPACITY_MAP      0xA210
      #define BUMP_MAP         0xA230
      #define SPECULAR_MAP     0xA204
      #define GLOSSINESS_MAP   0xA33C
      #define SELF_ILUM_MAP    0xA33D
      #define REFLECTION_MAP   0xA220
      #define MAT_TEXTURE2     0xA33A
        #define MAP_FILENAME    0xA300
        #define MAP_OPTIONS     0xA351
		#define MAP_BLUR        0xA353
        #define U_SCALE         0xA354
        #define V_SCALE         0xA356
        #define U_OFFSET        0xA358
        #define V_OFFSET        0xA35A
        #define MAP_ROTATION_ANGLE 0xA35C
        #define TINT_FIRST_COLOR 0xA360
        #define TINT_SECOND_COLOR 0xA362
        #define R_CHANEL_COLOR  0xA364
        #define G_CHANEL_COLOR  0xA366
        #define B_CHANEL_COLOR  0xA368
      
    #define EDIT_CONFIG1  0x0100
    #define EDIT_CONFIG2  0x3D3E  //Pay atention, need to fix it??
    #define EDIT_VIEW_P1  0x7012
    #define EDIT_VIEW_P2  0x7011
      #define TOP           0x0001
      #define BOTTOM        0x0002
      #define LEFT          0x0003
      #define RIGHT         0x0004
      #define FRONT         0x0005
      #define BACK          0x0006
      #define USER          0x0007
      #define CAMERA        0x0008 // 0xFFFF is the code read from file
      #define LIGHT         0x0009
      #define DISABLED      0x0010
      #define BOGUS         0x0011
    #define EDIT_VIEW_P3  0x7020
    #define EDIT_VIEW1    0x7001
    #define EDIT_BACKGR   0x1200
    #define EDIT_AMBIENT  0x2100
    #define EDIT_OBJECT   0x4000
      #define OBJ_TRIMESH   0x4100
        #define TRI_VERTEXL         0x4110
        #define TRI_VERTEXOPTIONS   0x4111 // unknown yet
        #define TRI_MAPPINGCOORS    0x4140
        #define TRI_MAPPINGSTANDARD 0x4170
        #define TRI_FACEL1    0x4120
          #define TRI_SMOOTH    0x4150
          #define TRI_MATERIAL  0x4130
        #define TRI_LOCAL     0x4160
        #define TRI_VISIBLE   0x4165
      #define OBJ_LIGHT     0x4600
        #define LIT_SPOT              0x4610
        #define LIT_OFF               0x4620
        #define FAR_ATTENUATION_START 0x4659
        #define FAR_ATTENUATION_END   0x465A
        #define LIT_MULTIPLIER        0x465B
        #define RAY_BIAS              0x4658
        #define LOCAL_SHADOW2         0x4641
        #define SPOT_ROLL             0x4656
      #define OBJ_CAMERA    0x4700
        #define CAM_UNKNWN01  0x4710 // new chunk type
        #define CAM_RANGES    0x4720 // new chunk type
      #define OBJ_UNKNWN01  0x4010
      #define OBJ_UNKNWN02  0x4012 //>>---- Could be shadow !!pay atention
    #define EDIT_UNKNW01  0x1100
    #define EDIT_UNKNW02  0x1201
    #define EDIT_UNKNW03  0x1300
    #define EDIT_UNKNW04  0x1400
    #define EDIT_UNKNW05  0x1420
    #define EDIT_UNKNW06  0x1450
    #define EDIT_UNKNW07  0x1500
    #define EDIT_UNKNW08  0x2200
    #define EDIT_UNKNW09  0x2201
    #define EDIT_UNKNW10  0x2210
    #define EDIT_UNKNW11  0x2300
    #define EDIT_UNKNW12  0x2302 // new chunk type
    #define EDIT_UNKNW13  0x3000 //!!pay atention
    #define EDIT_UNKNW14  0xAFFF
  #define KEYF3DS       0xB000  // this is the start of the keyframer config
    #define KEYF_CUR_FRAME  0xB009
    #define KEYF_HEADER     0xB00A  //!pay atention please!!!!!
    #define KEYF_FRAMES     0xB008
    #define OBJECT_NODE_TAG 0xB002
      #define KEYF_OBJHIERARCH  0xB010
      #define KEYF_OBJDUMMYNAME 0xB011
      #define KEYF_PIVOT        0xB013
      #define KEYF_OBJUNKNWN02  0xB014
      #define KEYF_OBJUNKNWN03  0xB015  
      
      #define POSITION_TRACK_TAG      0xB020  
      #define ROTATION_TRACK_TAG      0xB021  
      #define SCALE_TRACK_TAG         0xB022
      
      #define FOV_CAM_TRACK_TAG       0xB023
      #define ROLL_CAM_TRACK_TAG      0xB024
      #define COLOR_TRACK_TAG         0xB025
      #define MORPH_TRACK_TAG         0xB026
      #define HOT_SPOT_TRACK_TAG      0xB027
      #define FALLOFF_TRACK_TAG       0xB028
      #define HIDE_TRACK_TRACK_TAG    0xB029
      
      #define NODE_ID           0xB030

#define COL_RGB  0x0010
#define COL_TRU  0x0011
#define COL_UNK  0x0013 // unknown


namespace Modeling {

class Ds3Stream : Modeling::AppStream
{
public:
	virtual ~Ds3Stream();
	Ds3Stream(std::string filename);

	size_t read(Modeling::Scene* scene);
	size_t write(Modeling::Scene* scene);

private:
	FILE* file;

//	void readMaterialChunk(Modeling::VisualNode* node, FILE* nodeFile, unsigned int EditMaterial_chunk_length);
//	void readMapChunk(Modeling::Mapp* mapp, FILE* nodeFile, unsigned int Map_chunk_length);
//	void readKeyFramerChunk(Modeling::VisualNode* node, FILE* nodeFile, unsigned int Keyf3ds_chunk_length);
};

}// namespace Modeling

#endif
